package com.he.controller;

import com.he.entity.OrderPriceParams;
import com.he.entity.OrderPriceResult;
import com.he.entity.Orders;
import com.he.entity.ResultData;
import com.he.login.IsLogin;
import com.he.service.IOrderService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
@Log4j2
public class OrderController {

    @Autowired
    private IOrderService orderService;

    /**
     * 获取订单价格明细
     * @param priceParams
     * @return
     */
    @RequestMapping("/getPrice")
    public ResultData<OrderPriceResult> getOrderPrice(OrderPriceParams priceParams){
        OrderPriceResult orderPrice = orderService.getOrderPrice(priceParams);
        System.out.println("---------->>>>>"+orderPrice);
        return new ResultData<OrderPriceResult>().setData(orderPrice);
    }

    /**
     * 下单
     * @return
     */
    @IsLogin(mustLogin = true)
    @RequestMapping("/insert")
    public ResultData<String> insertOrder(Orders orders, OrderPriceParams orderPriceParams){
        System.out.println("下单对象：" + orders);
        System.out.println("价格参数对象：" + orderPriceParams);
        String orderId = orderService.insertOrder(orders, orderPriceParams);
        return new ResultData<String>().setData(orderId);
    }
}
